package com.ptszyxx.popose.module.main.mine.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.databinding.ItemMineIntimacyBinding;
import com.ptszyxx.popose.module.main.mine.vm.MineFollowTabVM;
import com.ptszyxx.popose.module.main.mine.vm.MineVipVM;
import com.ysg.http.data.entity.mine.IntimacyEntity;
import com.ysg.http.data.entity.mine.VipEntity;

public class MineIntimacyAdapter extends BaseQuickAdapter<IntimacyEntity, BaseDataBindingHolder<ItemMineIntimacyBinding>> {

    private MineFollowTabVM viewModel;
    private Presenter mPresenter = new Presenter();
    private int currentPosition = 0;

    public MineIntimacyAdapter(MineFollowTabVM viewModel) {
        super(R.layout.item_mine_intimacy);
        this.viewModel = viewModel;
    }

    public void setPosition(int position) {
        this.currentPosition = position;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseDataBindingHolder<ItemMineIntimacyBinding> holder, IntimacyEntity item) {
        ItemMineIntimacyBinding binding = holder.getDataBinding();
        if (binding != null) {
            binding.setEntity(item);
            binding.setViewModel(viewModel);
            binding.setPresenter(mPresenter);
            binding.setPosition(holder.getBindingAdapterPosition());
            binding.executePendingBindings();
        }
    }

    public static class Presenter{
        public void onItemClick(MineVipVM viewModel, VipEntity entity, int position){
            viewModel.onItemClick(entity, position);
        }
    }

}
